package br.senac.sp.hsqldb;

import br.senac.sp.IConnectorFactory;
import br.senac.sp.persistence.IConnector;
import br.senac.sp.persistence.RelationalDBConnector;

import java.sql.DriverManager;

public class HsqldbMemoryConnectorFactory implements IConnectorFactory {

    public static HsqldbMemoryConnectorFactory getInstance() {
        if(instance == null) instance = new HsqldbMemoryConnectorFactory();
        return instance;
    }

    private static HsqldbMemoryConnectorFactory instance;

    private HsqldbMemoryConnectorFactory () {
        try {
            Class.forName("org.hsqldb.jdbcDriver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException();
        }
    }
    @Override
    public IConnector createConnector() {
        return new RelationalDBConnector("jdbc:hsqldb:mem:senac-persistence", "SA", "");
    }
}
